package oj;

public class Num226 {
    public TreeNode invertTree(TreeNode root) {
        if(root==null){
            return null;
        }
        return invert(root);
    }
    public TreeNode invert(TreeNode root) {
        if(root==null){
            return null;
        }
        TreeNode treeNode=new TreeNode(root.val);
        treeNode.left=invertTree(root.right);
        treeNode.right=invertTree(root.left);
        return treeNode;
    }
}
